package com.muyu.danmo.controller;


import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.danmo.service.IDanmoOnlineUpgradeService;
import com.muyu.system.domain.DanmoOnlineUpgrade;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 版本更新Controller
 * 
 * @author yangle
 * @date 2025-04-07
 */
@RestController
@RequestMapping("/onlineUpgrade")
public class DanmoOnlineUpgradeController extends BaseController
{
    @Autowired
    private IDanmoOnlineUpgradeService danmoOnlineUpgradeService;

    /**
     * 查询版本更新列表
     */
//    @RequiresPermissions("system:onlineUpgrade:list")
    @PostMapping("/list")
    public Result<List<DanmoOnlineUpgrade>> list(@RequestBody  DanmoOnlineUpgrade danmoOnlineUpgrade)
    {

        List<DanmoOnlineUpgrade> list = danmoOnlineUpgradeService.selectDanmoOnlineUpgradeList(danmoOnlineUpgrade);
        return Result.success(list);
    }

    /**
     * 导出版本更新列表
     */
//    @RequiresPermissions("system:onlineUpgrade:export")
    @Log(title = "版本更新", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoOnlineUpgrade danmoOnlineUpgrade)
    {
        List<DanmoOnlineUpgrade> list = danmoOnlineUpgradeService.selectDanmoOnlineUpgradeList(danmoOnlineUpgrade);
        ExcelUtil<DanmoOnlineUpgrade> util = new ExcelUtil<DanmoOnlineUpgrade>(DanmoOnlineUpgrade.class);
        util.exportExcel(response, list, "版本更新数据");
    }

    /**
     * 获取版本更新详细信息
     */
//    @RequiresPermissions("system:onlineUpgrade:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") String id)
    {
        return success(danmoOnlineUpgradeService.selectDanmoOnlineUpgradeById(id));
    }

    /**
     * 新增版本更新
     */
//    @RequiresPermissions("system:onlineUpgrade:add")
    @Log(title = "版本更新", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoOnlineUpgrade danmoOnlineUpgrade)
    {
        int i = danmoOnlineUpgradeService.insertDanmoOnlineUpgrade(danmoOnlineUpgrade);
        return Result.success(i,"新增成功");
    }

    /**
     * 修改版本更新
     */
//    @RequiresPermissions("system:onlineUpgrade:edit")
    @Log(title = "版本更新", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoOnlineUpgrade danmoOnlineUpgrade)
    {
        int i = danmoOnlineUpgradeService.updateDanmoOnlineUpgrade(danmoOnlineUpgrade);
        return Result.success(i,"修改成功");
    }

    /**
     * 删除版本更新
     */
//    @RequiresPermissions("system:onlineUpgrade:remove")
    @Log(title = "版本更新", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable String[] ids)
    {
        int i = danmoOnlineUpgradeService.deleteDanmoOnlineUpgradeByIds(ids);
        return Result.success(i,"删除成功");
    }
}
